import java.util.Scanner;
import java.util.*;

public class MC0455四大名著西游签到 {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        // code here
        int n = input.nextInt();
        for (int i = 0; i < n; i++) {
            StringBuilder sb1 = new StringBuilder();
            StringBuilder sb2 = new StringBuilder();
            String s1 = input.next();
            String s2 = input.next();
            for (int j = 0; j <s1.length(); j++) {
                if (s1.charAt(j) != s2.charAt(j)){
                    sb1.append(s1.charAt(j));
                    sb2.append(s2.charAt(j));
                }
            }
            if (sb1.toString().contentEquals(sb2.reverse())){
                System.out.println("Y");
            }
            else{
                System.out.println("N");
            }
        }
        input.close();
    }
}
